package com.tocchisu.tv.services.trends;

import com.tocchisu.tv.model.News;
import com.tocchisu.tv.model.Slot;
import com.tocchisu.tv.model.Telegram;

public class NewsInfluence implements Trend {

  public float getTrend(Slot slot) {
    News news = slot.getNews();
    float result = 0;
    float maxBuzzFactor = 0;
    for (Telegram telegram : news.getTelegrams()) {
      float buzzFactor = telegram.getBuzzFactor();
      if (buzzFactor > maxBuzzFactor) {
        maxBuzzFactor = buzzFactor;
      }
      result += buzzFactor;
    }
    result = result - maxBuzzFactor;
    result = maxBuzzFactor + .5F * (100 - maxBuzzFactor) * result;
    return result - maxBuzzFactor;
  }
}